Learn R Programming

fastR (version 1.1)

The nth largest value of a vector: The nth largest value of a vector

Description

he nth largest value of a vector.

Usage

nth(x, k)

Arguments

x
A numerical vector.
k
The kth largest number to be returned.

Value

The desired value.

Details

The function is written in C++ and this is why it is very fast. This is called (and used) by colMedians.

See Also

colMedians

Examples

Run this code
x <- rnorm(10000)
nth(x, 5000)
sort(x)[5000]

Run the code above in your browser using DataLab